import request from '@/utile/request.js'
import store from '@/store/index.js'
const postDislikeAPI = ({ target }) => {
  return request({
    method: 'POST',
    url: '/v1_0/article/dislikes',
    headers: {
      Authorization: 'Bearer ' + store.state.token
    },
    data: {
      target
    }
  })
}
const reportArticleAPI = ({ target, type, remark }) => {
  request({
    url: '/v1_0/article/reports',
    method: 'POST',
    headers: {
      Authorization: `Bearer ${store.state.token}`
    },
    data: {
      target,
      type,
      remark
    }
  })
}
const articleDetailAPI = ({ id }) => {
  return request({
    url: `/v1_0/articles/${id}`
  })
}
const attentionAPI = ({ target }) => {
  return request({
    url: '/v1_0/user/followings',
    method: 'POST',
    data: {
      target: target
    },
    headers: {
      Authorization: 'Bearer ' + store.state.token
    }
  })
}
const delAttentionAPI = ({ target }) => {
  return request({
    url: `/v1_0/user/followings/${target}`,
    method: 'DELETE',
    Authorization: 'Bearer ' + store.state.token
  })
}
const likeArticleAPI = ({ target }) => {
  return request({
    url: '/v1_0/article/likings',
    method: 'POST',
    data: {
      target
    }
  })
}
const dislikeArticleAPI = ({ target }) => {
  return request({
    url: `/v1_0/article/likings/${target}`,
    method: 'DELETE'
  })
}
export {
  postDislikeAPI,
  reportArticleAPI,
  articleDetailAPI,
  attentionAPI,
  delAttentionAPI,
  likeArticleAPI,
  dislikeArticleAPI
}
